package org.jflame.web.spring.aop;

import org.jflame.context.spring.aop.KeyExprParser;
import org.jflame.web.WebUtils;
import org.jflame.web.spring.SpringWebUtils;

import java.lang.reflect.Method;

public class ClientIpKeyParser implements KeyExprParser {

    @Override
    public boolean support(String keyExpression) {
        return "@ip".equals(keyExpression);
    }

    @Override
    public String parse(String key, Method method, Object[] methodArgs) {
        return WebUtils.getRemoteClientIP(SpringWebUtils.getRequest());
    }

}
